var app = getApp();
Page({
  data: {
    Arr: [],
    page: 0,
    prenumber: 8,
    height: "",
    Kind:['推荐','冬日养生','食疗'],
    type:0
  },
  //选类
  whichKind:function(e){
    let index = e.currentTarget.dataset.index;
    this.setData({
      type: index
    })
  },
  lower: function() {
    if (!this.data.noFlag && !this.data.closureFlag) {
      this.setData({
        closureFlag: !0
      });
      var t, e = this,
        s = e.data.prenumber,
        i = e.data.page,
        n = e.data.Arr;
      wx.request({
        url: a.globalData.hbpublic + "news/list/" + i + "/" + s + "/1",
        data: {},
        success: function(a) {
          if (t = n.concat(a.data.data), 200 == a.data.code) {
            if (i++, e.setData({
                page: i
              }), e.setData({
                Arr: t
              }), null == a.data.data || a.data.data.length <= 0) return e.setData({
              noFlag: !0,
              closureFlag: !1
            }), !1;
            wx.showLoading({
              title: "加载中",
              icon: "loading"
            }), e.setData({
              Arr: t,
              closureFlag: !1
            }), setTimeout(function() {
              wx.hideLoading();
            }, 1500);
          }
        }
      });
    }
  },
  onLoad: function(a) {
    var t = this;
    wx.getSystemInfo({
      success: function(a) {
        t.setData({
          height: a.windowHeight + 100
        });
      }
    });
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    t.setData({
      bgc: bgc
    })
    app.util.request({
      'url': 'entry/wxapp/Zixun',
      success: function(res) {
        console.log(res)
        t.setData({
          Arr: res.data.data,
          page: 1,
        });
      }
    })

  },
  toast: function () {
    wx.redirectTo({
      url: '/hyb_yl/tabBar/index/index'
    })
  },
  toast1: function (e) {
    //console.log(e)
    wx.redirectTo({
      url: '/hyb_yl/tabBar/community/community'
    })
  },
  toast2: function () {
    wx.redirectTo({
      url: '/hyb_yl/tabBar/shop/shop'
    })
  },
  toast3: function () {
    var openid = wx.getStorageSync('openid');
    app.util.request({
      'url': 'entry/wxapp/Myphone',
      data: {
        openid: openid
      },
      success: function (res) {
        app.globalData.myphone = res.data.data
        app.globalData.openid = openid
      },
      fail: function (err) {
        console.log(err)
      },

    })
    setTimeout(function () {
      wx.redirectTo({
        url: '/hyb_yl/tabBar/my/my'
      })
    }, 350)
  },
  toast4() {
    app.util.request({
      'url': 'entry/wxapp/Myphone',
      data: {
        openid: openid
      },
      success: function (res) {
        app.globalData.myphone = res.data.data
        app.globalData.openid = openid
      },
      fail: function (err) {
        console.log(err)
      },

    })
    wx.redirectTo({
      url: '/hyb_yl/userLife/pages/jibingyufang/jibingyufang'
    })
  },
  onShow: function() {
    // var t = this;
    // this.setData({
    //   noFlag: !1
    // }), wx.request({
    //   url: a.globalData.hbpublic + "news/list/0/8/1",
    //   data: {},
    //   success: function(a) {
    //     t.setData({
    //       Arr: a.data.data,
    //       page: 1
    //     });
    //   }
    // });
  },
  nav: function(a) {
    console.log(a)
    var id = a.currentTarget.dataset.id
    // wx.setStorageSync("advisory", a.currentTarget.dataset.id),
    wx.navigateTo({
      url: "/hyb_yl/backstageLife/pages/advisory1/advisory1?id=" + id
    });
  }
});